package sktit.practice.jpaint.shape;

import java.util.ArrayList;

import org.eclipse.swt.graphics.Point;

public class Rectangle extends Polygon {
	
	public Rectangle(ArrayList<Point> p)
	{
		super(p);
	}
	
	@Override
	public double getArea()
	{
		int width = Math.abs(vertex.get(0).x - vertex.get(1).x);
		int height = Math.abs(vertex.get(0).y - vertex.get(1).y);
		return width * height;
	}
	
	@Override
	public double getPerimeter()
	{
		int width = Math.abs(vertex.get(0).x - vertex.get(1).x);
		int height = Math.abs(vertex.get(0).y - vertex.get(1).y);
		return 2*(width + height);
	}
	
}
